﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace spacex.util.Converters
{
    /// <summary>
    /// Converter converts the passed window height to the appropriate grid height
    /// </summary>
    public class WindowHeightConverter : IMultiValueConverter
    {
        /// <summary>
        /// Converts the window height into the grid height
        /// </summary>
        /// <param name="values">The window height and the header height</param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values == null)
            {
                return 500;
            }
            else
            {
                double windowHeight = double.Parse(values[0].ToString());
                double headerHeight = double.Parse(values[1].ToString());

                return windowHeight - headerHeight;
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
